package com.ruoyi.security.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.domain.AfInspection;
import com.ruoyi.security.mapper.AfInspectionMapper;
import com.ruoyi.security.service.IAfInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 巡检Service业务层处理
 *
 * @author cjie
 * @date 2021-07-24
 */
@Service
public class AfInspectionServiceImpl implements IAfInspectionService {
    @Autowired
    private AfInspectionMapper afInspectionMapper;

    /**
     * 查询巡检
     *
     * @param id 巡检ID
     * @return 巡检
     */
    @Override
    public AfInspection selectAfInspectionById(String id) {
        return afInspectionMapper.selectAfInspectionById(id);
    }

    /**
     * 查询巡检列表
     *
     * @param afInspection 巡检
     * @return 巡检
     */
    @Override
    public List<AfInspection> selectAfInspectionList(AfInspection afInspection) {
        return afInspectionMapper.selectAfInspectionList(afInspection);
    }

    /**
     * 新增巡检
     *
     * @param afInspection 巡检
     * @return 结果
     */
    @Override
    public int insertAfInspection(AfInspection afInspection) {
        afInspection.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afInspection.setCreateTime(DateUtils.getNowDate());
        afInspection.setCreateBy(SecurityUtils.getUsername());
        return afInspectionMapper.insertAfInspection(afInspection);
    }

    /**
     * 修改巡检
     *
     * @param afInspection 巡检
     * @return 结果
     */
    @Override
    public int updateAfInspection(AfInspection afInspection) {
        afInspection.setUpdateTime(DateUtils.getNowDate());
        afInspection.setUpdateBy(SecurityUtils.getUsername());
        return afInspectionMapper.updateAfInspection(afInspection);
    }

    /**
     * 批量删除巡检
     *
     * @param ids 需要删除的巡检ID
     * @return 结果
     */
    @Override
    public int deleteAfInspectionByIds(String[] ids) {
        return afInspectionMapper.deleteAfInspectionByIds(ids);
    }

    /**
     * 删除巡检信息
     *
     * @param id 巡检ID
     * @return 结果
     */
    @Override
    public int deleteAfInspectionById(String id) {
        return afInspectionMapper.deleteAfInspectionById(id);
    }
}
